﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Windows.Storage;
using Windows.UI.Xaml.Controls;
using XConductor.Domain.Seedwork.Playback.Settings;

namespace XConductor.Domain.WP8.Playback.Settings
{
    public class AudioPlayerSettingsService : IAudioPlayerSettingsService
    {
        private MediaElement m_mediaElement;

        public AudioPlayerSettingsService(MediaElement mediaElement)
        {
            this.m_mediaElement = mediaElement;
        }

        public async Task<IAudioPlayerSettings> PlayFromFile(string path)
        {
            var fiels = await KnownFolders.VideosLibrary.GetFilesAsync();
            
            return new AudioPlayerSettings 
            {
                InputFile = fiels.FirstOrDefault(f => f.Name.Equals(path, StringComparison.OrdinalIgnoreCase)),
                MediaElement = this.m_mediaElement,
            };
        }
    }
}
